package com.xjc.business.controller.buildadmin;

import com.xjc.business.entity.po.buildadmin.BuildAdminLogoPo;
import com.xjc.business.entity.po.classadmin.ClassAdminLogoPo;
import com.xjc.business.entity.vo.buildadmin.BuildAdminLoginVo;
import com.xjc.business.entity.vo.classadmin.ClassAdminLoginVo;
import com.xjc.business.service.BuildingAdminsService;
import com.xjc.business.service.ClassAdminsService;
import com.xjc.system.constants.MyConstants;
import com.xjc.system.exception.MyException;
import com.xjc.system.result.Result;
import com.xjc.system.result.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 徐锦程
 * 时间:2025-01-30 22:03
 */
@RestController
@RequestMapping("/build_admin/user")
public class BuildUserController {

    @Autowired
    BuildingAdminsService buildingAdminsService;

    /**
     * 登录
     * @param buildAdminLogoPo 登录参数
     * @return 登录成功返回token，失败返回错误信息
     */
    @PostMapping("/login")
    public Result<BuildAdminLoginVo> doLogin(@RequestBody(required = false) BuildAdminLogoPo buildAdminLogoPo){
        if(buildAdminLogoPo == null || buildAdminLogoPo.getUsername() == null || buildAdminLogoPo.getPassword() == null){
            throw new MyException(ResultCode.SUCCESS.getCode(), MyConstants.PARAM_MISSING);
        }
        return buildingAdminsService.doLogin(buildAdminLogoPo);
    }
}
